home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / db3.6-beta / db3.6-beta-src / designgui.c < prev    next >
C/C++ Source or Header  |  1999-11-30  |  31KB  |  853 lines

  1. /*
  2.  *  Source machine generated by GadToolsBox V2.0b
  3.  *  which is (c) Copyright 1991-1993 Jaba Development
  4.  *
  5.  *  GUI Designed by : David Ekholm, Datadosen
  6.  */
  7.  
  8. #include <exec/types.h>
  9. #include <intuition/intuition.h>
  10. #include <intuition/classes.h>
  11. #include <intuition/classusr.h>
  12. #include <intuition/imageclass.h>
  13. #include <intuition/gadgetclass.h>
  14. #include <libraries/gadtools.h>
  15. #include <graphics/displayinfo.h>
  16. #include <graphics/gfxbase.h>
  17. #include <clib/exec_protos.h>
  18. #include <clib/intuition_protos.h>
  19. #include <clib/gadtools_protos.h>
  20. #include <clib/graphics_protos.h>
  21. #include <clib/utility_protos.h>
  22. #include <string.h>
  23. #include <pragmas/exec_pragmas.h>
  24. #include <pragmas/intuition_pragmas.h>
  25. #include <pragmas/gadtools_pragmas.h>
  26. #include <pragmas/graphics_pragmas.h>
  27. #include <pragmas/utility_pragmas.h>
  28.  
  29. #include "DesignGUI.h"
  30. #include "DesignGUI_fix.h"
  31.  
  32. #define CATCOMP_NUMBERS
  33. #include "db.h"
  34.  
  35. /*
  36. static struct Window         *MainWnd = NULL;
  37. static struct Window         *TagWnd = NULL;
  38. static struct Window         *NameWnd = NULL;
  39. static struct Window         *FieldWnd = NULL;
  40. */
  41. struct Window         *VisWnd = NULL;
  42.  
  43. /*
  44. static struct Gadget         *MainGList = NULL;
  45. static struct Gadget         *TagGList = NULL;
  46. static struct Gadget         *NameGList = NULL;
  47. static struct Gadget         *FieldGList = NULL;
  48. */
  49. static struct Gadget         *VisGList = NULL;
  50.  
  51. struct Menu           *DesignMenus = NULL;
  52. /*
  53. struct IntuiMessage    MainMsg;
  54. struct IntuiMessage    TagMsg;
  55. struct IntuiMessage    NameMsg;
  56. struct IntuiMessage    FieldMsg;
  57. */
  58. struct IntuiMessage    VisMsg;
  59. /*
  60. static struct Gadget         *MainGadgets[11];
  61. static struct Gadget         *TagGadgets[4];
  62. static struct Gadget         *NameGadgets[3];
  63. static struct Gadget         *FieldGadgets[5];
  64. */
  65. struct Gadget         *VisGadgets[8];
  66. /*
  67. static UWORD                  MainLeft = 227;
  68. static UWORD                  MainTop = 186;
  69. static UWORD                  MainWidth = 305;
  70. static UWORD                  MainHeight = 182;
  71. static UWORD                  TagLeft = 89;
  72. static UWORD                  TagTop = 162;
  73. static UWORD                  TagWidth = 489;
  74. static UWORD                  TagHeight = 63;
  75. static UWORD                  NameLeft = 237;
  76. static UWORD                  NameTop = 199;
  77. static UWORD                  NameWidth = 283;
  78. static UWORD                  NameHeight = 64;
  79. static UWORD                  FieldLeft = 149;
  80. static UWORD                  FieldTop = 218;
  81. static UWORD                  FieldWidth = 329;
  82. static UWORD                  FieldHeight = 102;
  83. */
  84. static UWORD                  VisLeft = 150;
  85. static UWORD                  VisTop = 174;
  86. static UWORD                  VisWidth = 398;
  87. static UWORD                  VisHeight = 122;
  88. /*
  89. static UBYTE                 *MainWdt  = (UBYTE *)"List Window";
  90. static UBYTE                 *TagWdt   = (UBYTE *)"Edit tag";
  91. static UBYTE                 *NameWdt  = (UBYTE *)"Edit name";
  92. static UBYTE                 *FieldWdt = (UBYTE *)"Edit field object";
  93. static UBYTE                 *VisWdt = (UBYTE *)"Edit visual field object";
  94. */
  95. static struct TextAttr       *Font, Attr;
  96. static UWORD                  FontX, FontY;
  97. static UWORD                  OffX, OffY;
  98.  
  99. struct NewMenu DesignNewMenu[] = {
  100.         NM_TITLE,(STRPTR)MSG_PROJECT_MENU  , NULL, 0, NULL, NULL,
  101.         NM_ITEM, (STRPTR)MSG_EDVIEW_ABOUT  , NULL, 0, 0L  , (APTR)DesignPROJECT_ABOUT,
  102.         NM_ITEM, (STRPTR)MSG_EDVIEW_EXIT   , NULL, 0, 0L  , (APTR)DesignPROJECT_EXIT,
  103.  
  104.         NM_TITLE,(STRPTR)MSG_EDVIEW_EDIT   , NULL, 0, NULL, NULL,
  105.         NM_ITEM, (STRPTR)MSG_EDVIEW_UNDO   , NULL, NM_ITEMDISABLED, 0L, (APTR)DesignEDIT_UNDO,
  106.         NM_ITEM, (STRPTR)NM_BARLABEL, NULL ,0, 0L, NULL,
  107.         NM_ITEM, (STRPTR)MSG_EDVIEW_CUT    , NULL, 0, 0L, (APTR)DesignEDIT_CUT,
  108.         NM_ITEM, (STRPTR)MSG_EDVIEW_COPY   , NULL, 0, 0L, (APTR)DesignEDIT_COPY,
  109.         NM_ITEM, (STRPTR)MSG_EDVIEW_PASTE  , NULL, NM_ITEMDISABLED, 0L, (APTR)DesignEDIT_PASTE,
  110.  
  111.         NM_END, NULL, NULL, 0, 0L, NULL };
  112.  
  113. /*
  114. static UWORD MainGTypes[] = {
  115.         LISTVIEW_KIND,
  116.         BUTTON_KIND,
  117.         BUTTON_KIND,
  118.         BUTTON_KIND,
  119.         BUTTON_KIND,
  120.         BUTTON_KIND,
  121.         BUTTON_KIND,
  122.         BUTTON_KIND,
  123.         BUTTON_KIND,
  124.         BUTTON_KIND,
  125.         BUTTON_KIND
  126. };
  127.  
  128. static UWORD TagGTypes[] = {
  129.         STRING_KIND,
  130.         STRING_KIND,
  131.         BUTTON_KIND,
  132.         BUTTON_KIND
  133. };
  134.  
  135. static UWORD NameGTypes[] = {
  136.         STRING_KIND,
  137.         BUTTON_KIND,
  138.         BUTTON_KIND
  139. };
  140.  
  141. static UWORD FieldGTypes[] = {
  142.         STRING_KIND,
  143.         INTEGER_KIND,
  144.         BUTTON_KIND,
  145.         BUTTON_KIND,
  146.         BUTTON_KIND
  147. };
  148. */
  149. static UWORD VisGTypes[] = {
  150.         STRING_KIND,   // Name
  151.         INTEGER_KIND,  // size
  152.         BUTTON_KIND,   // ok
  153.         BUTTON_KIND,   // cancel
  154.         BUTTON_KIND,   // more
  155.         TEXT_KIND,     // field
  156.         BUTTON_KIND,   // select
  157.         CYCLE_KIND     // type
  158.  
  159. };
  160.  
  161. /*
  162. static struct NewGadget MainNGad[] = {
  163.         4, 20, 221, 117, (UBYTE *)"Object list", NULL, GD_LIST, PLACETEXT_ABOVE, NULL, (APTR)LISTClicked,
  164.         232, 20, 69, 17, (UBYTE *)"Top", NULL, GD_TOP, PLACETEXT_IN, NULL, (APTR)TOPClicked,
  165.         232, 44, 69, 17, (UBYTE *)"Up", NULL, GD_UP, PLACETEXT_IN, NULL, (APTR)UPClicked,
  166.         232, 68, 69, 17, (UBYTE *)"Down", NULL, GD_DOWN, PLACETEXT_IN, NULL, (APTR)DOWNClicked,
  167.         232, 92, 69, 17, (UBYTE *)"Bottom", NULL, GD_BOTTOM, PLACETEXT_IN, NULL, (APTR)BOTTOMClicked,
  168.         4, 136, 69, 17, (UBYTE *)"_New...", NULL, GD_NEW, PLACETEXT_IN, NULL, (APTR)NEWClicked,
  169.         80, 136, 69, 17, (UBYTE *)"_Edit...", NULL, GD_EDIT, PLACETEXT_IN, NULL, (APTR)EDITClicked,
  170.         156, 136, 69, 17, (UBYTE *)"Co_py", NULL, GD_COPY, PLACETEXT_IN, NULL, (APTR)COPYClicked,
  171.         232, 136, 69, 17, (UBYTE *)"Remove", NULL, GD_REMOVE, PLACETEXT_IN, NULL, (APTR)REMOVEClicked,
  172.         4, 160, 69, 17, (UBYTE *)"_Use", NULL, GD_USE, PLACETEXT_IN, NULL, (APTR)USEClicked,
  173.         232, 160, 69, 17, (UBYTE *)"_Cancel", NULL, GD_CANCEL, PLACETEXT_IN, NULL, (APTR)CANCELClicked
  174. };
  175.  
  176. static struct NewGadget TagNGad[] = {
  177.         190, 6, 292, 21, (UBYTE *)"_Value", NULL, GD_TAG_VALUE, PLACETEXT_LEFT, NULL, (APTR)TAG_VALUEClicked,
  178.         30, 6, 101, 21, (UBYTE *)"_ID", NULL, GD_TAG_ID, PLACETEXT_LEFT, NULL, (APTR)TAG_IDClicked,
  179.         6, 42, 61, 17, (UBYTE *)"_Ok", NULL, GD_TAG_OK, PLACETEXT_IN, NULL, (APTR)TAG_OKClicked,
  180.         422, 42, 61, 17, (UBYTE *)"_Cancel", NULL, GD_TAG_CANCEL, PLACETEXT_IN, NULL, (APTR)TAG_CANCELClicked
  181. };
  182.  
  183. static struct NewGadget NameNGad[] = {
  184.         52, 6, 225, 21, (UBYTE *)"_Name", NULL, GD_NAME_NAME, PLACETEXT_LEFT, NULL, (APTR)NAME_NAMEClicked,
  185.         6, 42, 61, 17, (UBYTE *)"_Ok", NULL, GD_NAME_OK, PLACETEXT_IN, NULL, (APTR)NAME_OKClicked,
  186.         215, 42, 61, 17, (UBYTE *)"_Cancel", NULL, GD_NAME_CANCEL, PLACETEXT_IN, NULL, (APTR)NAME_CANCELClicked
  187. };
  188.  
  189. static struct NewGadget FieldNGad[] = {
  190.         64, 8, 113, 21, (UBYTE *)"_Name", NULL, GD_FIELD_NAME, PLACETEXT_LEFT, NULL, (APTR)FIELD_NAMEClicked,
  191.         264, 8, 57, 21, (UBYTE *)"Max _length", NULL, GD_FIELD_MAXLEN, PLACETEXT_LEFT, NULL, (APTR)FIELD_MAXLENClicked,
  192.         4, 80, 69, 17, (UBYTE *)"_Ok", NULL, GD_FIELD_OK, PLACETEXT_IN, NULL, (APTR)FIELD_OKClicked,
  193.         256, 80, 69, 17, (UBYTE *)"_Cancel", NULL, GD_FIELD_CANCEL, PLACETEXT_IN, NULL, (APTR)FIELD_CANCELClicked,
  194.         128, 80, 69, 17, (UBYTE *)"_More...", NULL, GD_FIELD_MORE, PLACETEXT_IN, NULL, (APTR)FIELD_MOREClicked
  195. };
  196. */
  197.  
  198. static char *GadgetType_Labels[] = {
  199.        (char *)"String",
  200.        (char *)"Text",
  201.        (char *)"Textfield",
  202.        (char *)"Cycle",
  203.        (char *)"Checkbox",
  204.        NULL
  205. };
  206.  
  207. static struct NewGadget VisNGad[] = {
  208.          72,   8, 205, 21, (UBYTE *)"_Name"    , NULL, GD_VIS_NAME  , PLACETEXT_LEFT, NULL, (APTR)VIS_NAMEClicked,
  209.         348,   8,  46, 21, (UBYTE *)"Si_ze"    , NULL, GD_VIS_SIZE  , PLACETEXT_LEFT, NULL, (APTR)VIS_SIZEClicked,
  210.           4, 100,  79, 17, (UBYTE *)"_Ok"      , NULL, GD_VIS_OK    , PLACETEXT_IN  , NULL, (APTR)VIS_OKClicked,
  211.         315, 100,  78, 17, (UBYTE *)"_Cancel"  , NULL, GD_VIS_CANCEL, PLACETEXT_IN  , NULL, (APTR)VIS_CANCELClicked,
  212.         160, 100,  89, 17, (UBYTE *)"_More..." , NULL, GD_VIS_MORE  , PLACETEXT_IN  , NULL, (APTR)VIS_MOREClicked,
  213.          72,  36, 123, 21, (UBYTE *)"Field"    , NULL, GD_VIS_FIELD , PLACETEXT_LEFT, NULL, NULL,
  214.         205,  40,  75, 17, (UBYTE *)"Select...", NULL, GD_VIS_SELECT, PLACETEXT_IN  , NULL, (APTR)VIS_SELECTClicked,
  215.          72,  64, 322, 21, (UBYTE *)"_Type"    , NULL, GD_VIS_TYPE  , PLACETEXT_IN  , NULL, NULL
  216. };
  217.  
  218. /*
  219. static ULONG MainGTags[] = {
  220.         (TAG_DONE),
  221.         (TAG_DONE),
  222.         (TAG_DONE),
  223.         (TAG_DONE),
  224.         (TAG_DONE),
  225.         (GT_Underscore), '_', (TAG_DONE),
  226.         (GT_Underscore), '_', (TAG_DONE),
  227.         (GT_Underscore), '_', (TAG_DONE),
  228.         (GT_Underscore), '_', (TAG_DONE),
  229.         (GT_Underscore), '_', (TAG_DONE),
  230.         (GT_Underscore), '_', (TAG_DONE)
  231. };
  232.  
  233. static ULONG TagGTags[] = {
  234.         (GTST_MaxChars), 256, (GT_Underscore), '_', (TAG_DONE),
  235.         (GTST_MaxChars), 45, (GT_Underscore), '_', (TAG_DONE),
  236.         (GT_Underscore), '_', (TAG_DONE),
  237.         (GT_Underscore), '_', (TAG_DONE)
  238. };
  239.  
  240. static ULONG NameGTags[] = {
  241.         (GTST_MaxChars), 45, (GT_Underscore), '_', (TAG_DONE),
  242.         (GT_Underscore), '_', (TAG_DONE),
  243.         (GT_Underscore), '_', (TAG_DONE)
  244. };
  245.  
  246. static ULONG FieldGTags[] = {
  247.         (GTST_MaxChars), 45, (GT_Underscore), '_', (TAG_DONE),
  248.         (GTIN_Number), 200, (GTIN_MaxChars), 5, (GT_Underscore), '_', (TAG_DONE),
  249.         (GT_Underscore), '_', (TAG_DONE),
  250.         (GT_Underscore), '_', (TAG_DONE),
  251.         (GT_Underscore), '_', (TAG_DONE)
  252. };
  253. */
  254. static ULONG VisGTags[] = {
  255.         (GTST_MaxChars), 45  , (GT_Underscore), '_', (TAG_DONE),
  256.         (GTIN_Number)  , 25  , (GTIN_MaxChars), 3, (GT_Underscore), '_', (TAG_DONE),
  257.         (GT_Underscore), '_' , (TAG_DONE),
  258.         (GT_Underscore), '_' , (TAG_DONE),
  259.         (GT_Underscore), '_' , (GA_Disabled), TRUE, (TAG_DONE),
  260.         (GTTX_Border)  , TRUE, (TAG_DONE),
  261.         (GT_Underscore), '_' , (TAG_DONE),
  262.         (GT_Underscore), '_' , GTCY_Active, 0, GTCY_Labels, &GadgetType_Labels, (TAG_DONE)
  263. };
  264.  
  265. static UWORD ComputeX( UWORD value )
  266. {
  267.         return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
  268. }
  269.  
  270. static UWORD ComputeY( UWORD value )
  271. {
  272.         return(( UWORD )((( FontY * value ) + 6 ) / 13 ));
  273. }
  274.  
  275. static void ComputeFont( UWORD width, UWORD height )
  276. {
  277.         Font = &Attr;
  278.         Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
  279.         Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
  280.         FontX = Scr->RastPort.Font->tf_XSize;
  281.  
  282.         OffX = Scr->WBorLeft;
  283.         OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
  284.  
  285.         if ( width && height ) {
  286.                 if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
  287.                         goto UseTopaz;
  288.                 if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
  289.                         goto UseTopaz;
  290.         }
  291.         return;
  292.  
  293. UseTopaz:
  294.         Font->ta_Name = (STRPTR)"topaz.font";
  295.         FontX = FontY = Font->ta_YSize = 8;
  296. }
  297.  
  298. /// Old parts
  299. /*
  300. int HandleMainIDCMP( void )
  301. {
  302.         struct IntuiMessage     *m;
  303.         int                     (*func)();
  304.         BOOL                    running = TRUE;
  305.  
  306.         while( m = GT_GetIMsg( MainWnd->UserPort )) {
  307.  
  308.                 CopyMem(( char * )m, ( char * )&MainMsg, (long)sizeof( struct IntuiMessage ));
  309.  
  310.                 GT_ReplyIMsg( m );
  311.  
  312.                 switch ( MainMsg.Class ) {
  313.  
  314.                         case    IDCMP_REFRESHWINDOW:
  315.                                 GT_BeginRefresh( MainWnd );
  316.                                 GT_EndRefresh( MainWnd, TRUE );
  317.                                 break;
  318.  
  319.                         case    IDCMP_CLOSEWINDOW:
  320.                                 running = MainCloseWindow();
  321.                                 break;
  322.  
  323.                         case    IDCMP_VANILLAKEY:
  324.                                 running = MainVanillaKey();
  325.                                 break;
  326.  
  327.                         case    IDCMP_RAWKEY:
  328.                                 running = MainRawKey();
  329.                                 break;
  330.  
  331.                         case    IDCMP_GADGETUP:
  332.                         case    IDCMP_GADGETDOWN:
  333.                                 func = ( void * )(( struct Gadget * )MainMsg.IAddress )->UserData;
  334.                                 running = func();
  335.                                 break;
  336.                 }
  337.         }
  338.         return( running );
  339. }
  340.  
  341. int OpenMainWindow( void )
  342. {
  343.         struct NewGadget        ng;
  344.         struct Gadget   *g;
  345.         UWORD           lc, tc;
  346.         UWORD           wleft = MainLeft, wtop = MainTop, ww, wh;
  347.  
  348.         ComputeFont( MainWidth, MainHeight );
  349.  
  350.         ww = ComputeX( MainWidth );
  351.         wh = ComputeY( MainHeight );
  352.  
  353.         if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
  354.         if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
  355.  
  356.         if ( ! ( g = CreateContext( &MainGList )))
  357.                 return( 1L );
  358.  
  359.         for( lc = 0, tc = 0; lc < Main_CNT; lc++ ) {
  360.  
  361.                 CopyMem((char * )&MainNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  362.  
  363.                 ng.ng_VisualInfo = VisualInfo;
  364.                 ng.ng_TextAttr   = Font;
  365.                 ng.ng_LeftEdge   = OffX + ComputeX( ng.ng_LeftEdge );
  366.                 ng.ng_TopEdge    = OffY + ComputeY( ng.ng_TopEdge );
  367.                 ng.ng_Width      = ComputeX( ng.ng_Width );
  368.                 ng.ng_Height     = ComputeY( ng.ng_Height);
  369.  
  370.                 MainGadgets[ lc ] = g = CreateGadgetA((ULONG)MainGTypes[ lc ], g, &ng, ( struct TagItem * )&MainGTags[ tc ] );
  371.  
  372.                 while( MainGTags[ tc ] ) tc += 2;
  373.                 tc++;
  374.  
  375.                 if ( NOT g )
  376.                         return( 2L );
  377.         }
  378.  
  379.         if ( ! ( MainWnd = OpenWindowTags( NULL,
  380.                                 WA_Left,        wleft,
  381.                                 WA_Top,         wtop,
  382.                                 WA_Width,       ww + OffX + Scr->WBorRight,
  383.                                 WA_Height,      wh + OffY + Scr->WBorBottom,
  384.                                 WA_IDCMP,       LISTVIEWIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
  385.                                 WA_Flags,       WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP,
  386.                                 WA_Gadgets,     MainGList,
  387.                                 WA_Title,       MainWdt,
  388.                                 WA_PubScreen,   Scr,
  389.                                 TAG_DONE )))
  390.         return( 4L );
  391.  
  392.         GT_RefreshWindow( MainWnd, NULL );
  393.  
  394.         return( 0L );
  395. }
  396.  
  397. void CloseMainWindow( void )
  398. {
  399.         if ( MainWnd        ) {
  400.                 CloseWindow( MainWnd );
  401.                 MainWnd = NULL;
  402.         }
  403.  
  404.         if ( MainGList      ) {
  405.                 FreeGadgets( MainGList );
  406.                 MainGList = NULL;
  407.         }
  408. }
  409.  
  410. int HandleTagIDCMP( void )
  411. {
  412.         struct IntuiMessage     *m;
  413.         int                     (*func)();
  414.         BOOL                    running = TRUE;
  415.  
  416.         while( m = GT_GetIMsg( TagWnd->UserPort )) {
  417.  
  418.                 CopyMem(( char * )m, ( char * )&TagMsg, (long)sizeof( struct IntuiMessage ));
  419.  
  420.                 GT_ReplyIMsg( m );
  421.  
  422.                 switch ( TagMsg.Class ) {
  423.  
  424.                         case    IDCMP_REFRESHWINDOW:
  425.                                 GT_BeginRefresh( TagWnd );
  426.                                 GT_EndRefresh( TagWnd, TRUE );
  427.                                 break;
  428.  
  429.                         case    IDCMP_CLOSEWINDOW:
  430.                                 running = TagCloseWindow();
  431.                                 break;
  432.  
  433.                         case    IDCMP_VANILLAKEY:
  434.                                 running = TagVanillaKey();
  435.                                 break;
  436.  
  437.                         case    IDCMP_GADGETUP:
  438.                                 func = ( void * )(( struct Gadget * )TagMsg.IAddress )->UserData;
  439.                                 running = func();
  440.                                 break;
  441.                 }
  442.         }
  443.         return( running );
  444. }
  445.  
  446. int OpenTagWindow( void )
  447. {
  448.         struct NewGadget        ng;
  449.         struct Gadget   *g;
  450.         UWORD           lc, tc;
  451.         UWORD           wleft = TagLeft, wtop = TagTop, ww, wh;
  452.  
  453.         ComputeFont( TagWidth, TagHeight );
  454.  
  455.         ww = ComputeX( TagWidth );
  456.         wh = ComputeY( TagHeight );
  457.  
  458.         if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
  459.         if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
  460.  
  461.         if ( ! ( g = CreateContext( &TagGList )))
  462.                 return( 1L );
  463.  
  464.         for( lc = 0, tc = 0; lc < Tag_CNT; lc++ ) {
  465.  
  466.                 CopyMem((char * )&TagNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  467.  
  468.                 ng.ng_VisualInfo = VisualInfo;
  469.                 ng.ng_TextAttr   = Font;
  470.                 ng.ng_LeftEdge   = OffX + ComputeX( ng.ng_LeftEdge );
  471.                 ng.ng_TopEdge    = OffY + ComputeY( ng.ng_TopEdge );
  472.                 ng.ng_Width      = ComputeX( ng.ng_Width );
  473.                 ng.ng_Height     = ComputeY( ng.ng_Height);
  474.  
  475.                 TagGadgets[ lc ] = g = CreateGadgetA((ULONG)TagGTypes[ lc ], g, &ng, ( struct TagItem * )&TagGTags[ tc ] );
  476.  
  477.                 while( TagGTags[ tc ] ) tc += 2;
  478.                 tc++;
  479.  
  480.                 if ( NOT g )
  481.                         return( 2L );
  482.         }
  483.  
  484.         if ( ! ( TagWnd = OpenWindowTags( NULL,
  485.                                 WA_Left,        wleft,
  486.                                 WA_Top,         wtop,
  487.                                 WA_Width,       ww + OffX + Scr->WBorRight,
  488.                                 WA_Height,      wh + OffY + Scr->WBorBottom,
  489.                                 WA_IDCMP,       STRINGIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
  490.                                 WA_Flags,       WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  491.                                 WA_Gadgets,     TagGList,
  492.                                 WA_Title,       TagWdt,
  493.                                 WA_PubScreen,   Scr,
  494.                                 TAG_DONE )))
  495.         return( 4L );
  496.  
  497.         GT_RefreshWindow( TagWnd, NULL );
  498.  
  499.         return( 0L );
  500. }
  501.  
  502. void CloseTagWindow( void )
  503. {
  504.         if ( TagWnd        ) {
  505.                 CloseWindow( TagWnd );
  506.                 TagWnd = NULL;
  507.         }
  508.  
  509.         if ( TagGList      ) {
  510.                 FreeGadgets( TagGList );
  511.                 TagGList = NULL;
  512.         }
  513. }
  514.  
  515. int HandleNameIDCMP( void )
  516. {
  517.         struct IntuiMessage     *m;
  518.         int                     (*func)();
  519.         BOOL                    running = TRUE;
  520.  
  521.         while( m = GT_GetIMsg( NameWnd->UserPort )) {
  522.  
  523.                 CopyMem(( char * )m, ( char * )&NameMsg, (long)sizeof( struct IntuiMessage ));
  524.  
  525.                 GT_ReplyIMsg( m );
  526.  
  527.                 switch ( NameMsg.Class ) {
  528.  
  529.                         case    IDCMP_REFRESHWINDOW:
  530.                                 GT_BeginRefresh( NameWnd );
  531.                                 GT_EndRefresh( NameWnd, TRUE );
  532.                                 break;
  533.  
  534.                         case    IDCMP_CLOSEWINDOW:
  535.                                 running = NameCloseWindow();
  536.                                 break;
  537.  
  538.                         case    IDCMP_VANILLAKEY:
  539.                                 running = NameVanillaKey();
  540.                                 break;
  541.  
  542.                         case    IDCMP_GADGETUP:
  543.                                 func = ( void * )(( struct Gadget * )NameMsg.IAddress )->UserData;
  544.                                 running = func();
  545.                                 break;
  546.                 }
  547.         }
  548.         return( running );
  549. }
  550.  
  551. int OpenNameWindow( void )
  552. {
  553.         struct NewGadget        ng;
  554.         struct Gadget   *g;
  555.         UWORD           lc, tc;
  556.         UWORD           wleft = NameLeft, wtop = NameTop, ww, wh;
  557.  
  558.         ComputeFont( NameWidth, NameHeight );
  559.  
  560.         ww = ComputeX( NameWidth );
  561.         wh = ComputeY( NameHeight );
  562.  
  563.         if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
  564.         if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
  565.  
  566.         if ( ! ( g = CreateContext( &NameGList )))
  567.                 return( 1L );
  568.  
  569.         for( lc = 0, tc = 0; lc < Name_CNT; lc++ ) {
  570.  
  571.                 CopyMem((char * )&NameNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  572.  
  573.                 ng.ng_VisualInfo = VisualInfo;
  574.                 ng.ng_TextAttr   = Font;
  575.                 ng.ng_LeftEdge   = OffX + ComputeX( ng.ng_LeftEdge );
  576.                 ng.ng_TopEdge    = OffY + ComputeY( ng.ng_TopEdge );
  577.                 ng.ng_Width      = ComputeX( ng.ng_Width );
  578.                 ng.ng_Height     = ComputeY( ng.ng_Height);
  579.  
  580.                 NameGadgets[ lc ] = g = CreateGadgetA((ULONG)NameGTypes[ lc ], g, &ng, ( struct TagItem * )&NameGTags[ tc ] );
  581.  
  582.                 while( NameGTags[ tc ] ) tc += 2;
  583.                 tc++;
  584.  
  585.                 if ( NOT g )
  586.                         return( 2L );
  587.         }
  588.  
  589.         if ( ! ( NameWnd = OpenWindowTags( NULL,
  590.                                 WA_Left,        wleft,
  591.                                 WA_Top,         wtop,
  592.                                 WA_Width,       ww + OffX + Scr->WBorRight,
  593.                                 WA_Height,      wh + OffY + Scr->WBorBottom,
  594.                                 WA_IDCMP,       STRINGIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
  595.                                 WA_Flags,       WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  596.                                 WA_Gadgets,     NameGList,
  597.                                 WA_Title,       NameWdt,
  598.                                 WA_PubScreen,   Scr,
  599.                                 TAG_DONE )))
  600.         return( 4L );
  601.  
  602.         GT_RefreshWindow( NameWnd, NULL );
  603.  
  604.         return( 0L );
  605. }
  606.  
  607. void CloseNameWindow( void )
  608. {
  609.         if ( NameWnd        ) {
  610.                 CloseWindow( NameWnd );
  611.                 NameWnd = NULL;
  612.         }
  613.  
  614.         if ( NameGList      ) {
  615.                 FreeGadgets( NameGList );
  616.                 NameGList = NULL;
  617.         }
  618. }
  619.  
  620. int HandleFieldIDCMP( void )
  621. {
  622.         struct IntuiMessage     *m;
  623.         int                     (*func)();
  624.         BOOL                    running = TRUE;
  625.  
  626.         while( m = GT_GetIMsg( FieldWnd->UserPort )) {
  627.  
  628.                 CopyMem(( char * )m, ( char * )&FieldMsg, (long)sizeof( struct IntuiMessage ));
  629.  
  630.                 GT_ReplyIMsg( m );
  631.  
  632.                 switch ( FieldMsg.Class ) {
  633.  
  634.                         case    IDCMP_REFRESHWINDOW:
  635.                                 GT_BeginRefresh( FieldWnd );
  636.                                 GT_EndRefresh( FieldWnd, TRUE );
  637.                                 break;
  638.  
  639.                         case    IDCMP_CLOSEWINDOW:
  640.                                 running = FieldCloseWindow();
  641.                                 break;
  642.  
  643.                         case    IDCMP_VANILLAKEY:
  644.                                 running = FieldVanillaKey();
  645.                                 break;
  646.  
  647.                         case    IDCMP_GADGETUP:
  648.                                 func = ( void * )(( struct Gadget * )FieldMsg.IAddress )->UserData;
  649.                                 running = func();
  650.                                 break;
  651.                 }
  652.         }
  653.         return( running );
  654. }
  655.  
  656. int OpenFieldWindow( void )
  657. {
  658.         struct NewGadget        ng;
  659.         struct Gadget   *g;
  660.         UWORD           lc, tc;
  661.         UWORD           wleft = FieldLeft, wtop = FieldTop, ww, wh;
  662.  
  663.         ComputeFont( FieldWidth, FieldHeight );
  664.  
  665.         ww = ComputeX( FieldWidth );
  666.         wh = ComputeY( FieldHeight );
  667.  
  668.         if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
  669.         if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
  670.  
  671.         if ( ! ( g = CreateContext( &FieldGList )))
  672.                 return( 1L );
  673.  
  674.         for( lc = 0, tc = 0; lc < Field_CNT; lc++ ) {
  675.  
  676.                 CopyMem((char * )&FieldNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  677.  
  678.                 ng.ng_VisualInfo = VisualInfo;
  679.                 ng.ng_TextAttr   = Font;
  680.                 ng.ng_LeftEdge   = OffX + ComputeX( ng.ng_LeftEdge );
  681.                 ng.ng_TopEdge    = OffY + ComputeY( ng.ng_TopEdge );
  682.                 ng.ng_Width      = ComputeX( ng.ng_Width );
  683.                 ng.ng_Height     = ComputeY( ng.ng_Height);
  684.  
  685.                 FieldGadgets[ lc ] = g = CreateGadgetA((ULONG)FieldGTypes[ lc ], g, &ng, ( struct TagItem * )&FieldGTags[ tc ] );
  686.  
  687.                 while( FieldGTags[ tc ] ) tc += 2;
  688.                 tc++;
  689.  
  690.                 if ( NOT g )
  691.                         return( 2L );
  692.         }
  693.  
  694.         if ( ! ( FieldWnd = OpenWindowTags( NULL,
  695.                                 WA_Left,        wleft,
  696.                                 WA_Top,         wtop,
  697.                                 WA_Width,       ww + OffX + Scr->WBorRight,
  698.                                 WA_Height,      wh + OffY + Scr->WBorBottom,
  699.                                 WA_IDCMP,       STRINGIDCMP|INTEGERIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
  700.                                 WA_Flags,       WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  701.                                 WA_Gadgets,     FieldGList,
  702.                                 WA_Title,       FieldWdt,
  703.                                 WA_PubScreen,   Scr,
  704.                                 TAG_DONE )))
  705.         return( 4L );
  706.  
  707.         GT_RefreshWindow( FieldWnd, NULL );
  708.  
  709.         return( 0L );
  710. }
  711.  
  712. void CloseFieldWindow( void )
  713. {
  714.         if ( FieldWnd        ) {
  715.                 CloseWindow( FieldWnd );
  716.                 FieldWnd = NULL;
  717.         }
  718.  
  719.         if ( FieldGList      ) {
  720.                 FreeGadgets( FieldGList );
  721.                 FieldGList = NULL;
  722.         }
  723. }
  724. */
  725. //|
  726.  
  727. int HandleVisIDCMP( void )
  728. {
  729.         struct IntuiMessage     *m;
  730.         int                     (*func)();
  731.         BOOL                    running = TRUE;
  732.  
  733.         while( m = GT_GetIMsg( VisWnd->UserPort )) {
  734.  
  735.                 CopyMem(( char * )m, ( char * )&VisMsg, (long)sizeof( struct IntuiMessage ));
  736.  
  737.                 GT_ReplyIMsg( m );
  738.  
  739.                 switch ( VisMsg.Class ) {
  740.  
  741.                         case    IDCMP_REFRESHWINDOW:
  742.                                 GT_BeginRefresh( VisWnd );
  743.                                 GT_EndRefresh( VisWnd, TRUE );
  744.                                 break;
  745.  
  746.                         case    IDCMP_CLOSEWINDOW:
  747.                                 running = VisCloseWindow();
  748.                                 break;
  749.  
  750.                         case    IDCMP_VANILLAKEY:
  751.                                 running = VisVanillaKey();
  752.                                 break;
  753.  
  754.                         case    IDCMP_GADGETUP:
  755.                                 func = ( void * )(( struct Gadget * )VisMsg.IAddress )->UserData;
  756.                                 if(func)
  757.                                     running = func();
  758.                                 else
  759.                                     running = 0;
  760.                                 break;
  761.                 }
  762.         }
  763.         return( running );
  764. }
  765.  
  766. /*
  767. ** Edit item window
  768. */
  769.  
  770. int OpenVisWindow( void )
  771. {
  772.         struct NewGadget        ng;
  773.         struct Gadget   *g;
  774.         UWORD           lc, tc;
  775.         UWORD           wleft = VisLeft, wtop = VisTop, ww, wh;
  776.                 char i;
  777.  
  778.         /* Localization. Poor but works ;-) */
  779.         VisNGad[0].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_NAME);
  780.         VisNGad[1].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_SIZE);
  781.         VisNGad[2].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_OK);
  782.         VisNGad[3].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_CANCEL);
  783.         VisNGad[4].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_MORE);
  784.         VisNGad[5].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_FIELD);
  785.         VisNGad[6].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_SELECT);
  786.         VisNGad[7].ng_GadgetText = GetAppStr(MSG_EDVIEW_EDIT_TYPE);
  787.  
  788.         for(i=0; i<5; i++)
  789.                 GadgetType_Labels[i] = (char *)GetAppStr(MSG_EDVIEW_TYPE_0 + i);
  790.  
  791.  
  792.         ComputeFont( VisWidth, VisHeight );
  793.  
  794.         ww = ComputeX( VisWidth );
  795.         wh = ComputeY( VisHeight );
  796.  
  797.         if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
  798.         if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
  799.  
  800.         if ( ! ( g = CreateContext( &VisGList )))
  801.                 return( 1L );
  802.  
  803.         for( lc = 0, tc = 0; lc < Vis_CNT; lc++ ) {
  804.  
  805.                 CopyMem((char * )&VisNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
  806.  
  807.                 ng.ng_VisualInfo = VisualInfo;
  808.                 ng.ng_TextAttr   = Font;
  809.                 ng.ng_LeftEdge   = OffX + ComputeX( ng.ng_LeftEdge );
  810.                 ng.ng_TopEdge    = OffY + ComputeY( ng.ng_TopEdge );
  811.                 ng.ng_Width      = ComputeX( ng.ng_Width );
  812.                 ng.ng_Height     = ComputeY( ng.ng_Height);
  813.  
  814.                 VisGadgets[ lc ] = g = CreateGadgetA((ULONG)VisGTypes[ lc ], g, &ng, ( struct TagItem * )&VisGTags[ tc ] );
  815.  
  816.                 while( VisGTags[ tc ] ) tc += 2;
  817.                 tc++;
  818.  
  819.                 if ( NOT g )
  820.                         return( 2L );
  821.         }
  822.  
  823.         if ( ! ( VisWnd = OpenWindowTags( NULL,
  824.                                 WA_Left,        wleft,
  825.                                 WA_Top,         wtop,
  826.                                 WA_Width,       ww + OffX + Scr->WBorRight,
  827.                                 WA_Height,      wh + OffY + Scr->WBorBottom,
  828.                                 WA_IDCMP,       STRINGIDCMP|INTEGERIDCMP|BUTTONIDCMP|TEXTIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
  829.                                 WA_Flags,       WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  830.                                 WA_Gadgets,     VisGList,
  831.                                 WA_Title,       GetAppStr(MSG_EDVIEW_TITLE),
  832.                                 WA_PubScreen,   Scr,
  833.                                 TAG_DONE )))
  834.         return( 4L );
  835.  
  836.         GT_RefreshWindow( VisWnd, NULL );
  837.  
  838.         return( 0L );
  839. }
  840.  
  841. void CloseVisWindow( void )
  842. {
  843.         if ( VisWnd        ) {
  844.                 CloseWindow( VisWnd );
  845.                 VisWnd = NULL;
  846.         }
  847.  
  848.         if ( VisGList      ) {
  849.                 FreeGadgets( VisGList );
  850.                 VisGList = NULL;
  851.         }
  852. }
  853.